package yxy.apple.util.http;

public interface HTTPProtocol {
	public enum Scheme {
		Unknown, HTTP, HTTPS;
		public static Scheme lookup(String string) {
			if (string == null) {
				return Scheme.Unknown;
			}
			if (string.equalsIgnoreCase("http")) {
				return Scheme.HTTP;
			} else if (string.equalsIgnoreCase("https")) {
				return Scheme.HTTPS;
			} else {
				return Scheme.Unknown;
			}
		}
	}

	public enum Method {
		Unknown(
				"UNKNOWN"
		), Get(
				"GET"
		), Post(
				"POST"
		), Patch(
				"PATCH"
		), Options(
				"OPTIONS"
		);
		private String text = null;

		Method(String text) {
			this.text = text;
		}

		@Override
		public String toString() {
			return this.text;
		}

		public String text() {
			return this.text;
		}

		public static Method lookup(String name) {
			if (name.equalsIgnoreCase(Get.text)) {
				return Get;
			} else if (name.equalsIgnoreCase(Post.text)) {
				return Post;
			} else if (name.equalsIgnoreCase(Patch.text)) {
				return Patch;
			} else if (name.equalsIgnoreCase(Options.text)) {
				return Options;
			} else {
				return Unknown;
			}
		}
	}

	public enum Status {
		Unknown(
				0, "Unknown"
		), Continue(
				100, "Continue"
		), SwitchingProtocols(
				101, "Switching Protocols"
		), Processing(
				102, "Processing"
		), OK(
				200, "OK"
		), Created(
				201, "Created"
		), Accepted(
				202, "Accepted"
		), NonAuthoritativeInformation(
				203, "Non-Authoritative Information"
		), NoContent(
				204, "No Content"
		), ResetContent(
				205, "Reset Content"
		), PartialContent(
				206, "Partial Content"
		), MultiStatus(
				207, "Multi-Status"
		), MultipleChoices(
				300, "Multiple Choices"
		), MovedPermanently(
				301, "Moved Permanently"
		), MoveTemporarily(
				302, "Moved Temporarily"
		), SeeOther(
				303, "See Other"
		), NotModified(
				304, "Not Modified"
		), UseProxy(
				305, "Use Proxy"
		), SwitchProxy(
				305, "Switch Proxy"
		), TemporaryRedirect(
				307, "Temporary Redirect"
		), BadRequest(
				400, "Bad Request"
		), Unauthorized(
				401, "Unauthorized"
		), PaymentRequired(
				402, "Payment Required"
		), Forbidden(
				403, "Forbidden"
		), NotFound(
				404, "Not Found"
		), MethodNotAllowed(
				405, "Method Not Allowed"
		), NotAcceptable(
				406, "Not Acceptable"
		), ProxyAuthenticationRequired(
				407, "Proxy Authentication Required"
		), RequestTimeout(
				408, "Request Timeout"
		), Conflict(
				409, "Conflict"
		), Gone(
				410, "Gone"
		), LengthRequired(
				411, "Length Required"
		), PreconditionFailed(
				412, "Precondition Failed"
		), RequestEntityTooLarge(
				413, " Request Entity Too Large"
		), RequestURITooLong(
				414, "Request-URI Too Long"
		), UnsupportedMediaType(
				415, "Unsupported Media Type"
		), RequestedRangeNotSatisfiable(
				416, "Requested Range Not Satisfiable"
		), ExpectationFailed(
				417, "Expectation Failed"
		), TooManyConnections(
				421, "Too Many Connections"
		), UnprocessableEntity(
				422, "Unprocessable Entity"
		), Locked(
				423, "Locked"
		), FailedDependency(
				424, "Failed Dependency"
		), UnorderedCollection(
				425, "Unordered Collection"
		), UpgradeRequired(
				426, "Upgrade Required"
		), RetryWith(
				449, "Retry With"
		), UnavailableForLegalReasons(
				451, "Unavailable For Legal Reasons"
		), InternalServerError(
				500, "Internal Server Error"
		), NotImplemented(
				501, "Not Implemented"
		), BadGateway(
				502, "Bad Gateway"
		), ServiceUnavailable(
				503, "Service Unavailable"
		), GatewayTimeout(
				504, "Gateway Timeout"
		), HTTPVersionNotSupported(
				505, "HTTP Version Not Supported"
		), VariantAlsoNegotiates(
				506, "Variant Also Negotiates"
		), InsufficientStorage(
				507, "Insufficient Storage"
		), BandwidthLimitExceeded(
				509, "Bandwidth Limit Exceeded"
		), NotExtended(
				510, "Not Extended"
		), UnparseableResponseHeaders(
				600, " Unparseable Response Headers"
		);

		private int code = 0;
		private String text = null;

		Status(int code, String text) {
			this.code = code;
			this.text = text;
		}

		@Override
		public String toString() {
			return this.code + " " + this.text;
		}

		public int code() {
			return this.code;
		}

		public String text() {
			return this.text;
		}
	}

	public enum Version {
		V1_0(
				"1.0"
		), V1_1(
				"1.1"
		);
		private String version = null;

		Version(String version) {
			this.version = version;
		}

		@Override
		public String toString() {
			return this.text();
		}

		public String text() {
			return "HTTP/" + this.version;
		}
	}

	public static class HeaderKey {
		public static final String Accept = "accept";
		public static final String AcceptEncoding = "Accept-Encoding";
		public static final String AcceptLanguage = "Accept-Language";
		public static final String ContentType = "Content-Type";
		public static final String ContentEncoding = "Content-Encoding";
		public static final String ContentLength = "Content-Length";
		public static final String SetCookie = "Set-Cookie";
		public static final String Server = "Server";
		public static final String UserAgent = "User-Agent";
		public static final String Language = "Language";
		public static final String Connection = "Connection";
		public static final String XForwardedFor = "X-Forwarded-For";
		public static final String XRequestedWith = "X-Requested-With";
		public static final String VIA = "Via";
		public static final String XProxyId = "X-Proxy-Id";
		public static final String Location = "Location";
		public static final String ProxyConnection = "Proxy-Connection";
		public static final String Host = "Host";

		public static final String CacheControl = "Cache-Control";
		public static final String Referer = "Referer";
		public static final String Cookie = "Cookie";
		public static final String Origin = "Origin";
		public static final String AccessControlRequestMethod = "Access-Control-Request-Method";
		public static final String AccessControlRequestMethods = "Access-Control-Request-Methods";
		public static final String AccessControlRequestHeaders = "Access-Control-Request-Headers";
		public static final String AccessControlAllowMethods = "Access-Control-Allow-Methods";
		public static final String AccessControlAllowHeaders = "Access-Control-Allow-Headers";
		public static final String AccessControlAllowCredentials = "Access-Control-Allow-Credentials";
		public static final String AccessControlAllowOrigin = "Access-Control-Allow-Origin";
		public static final String AccessControlMaxAge = "Access-Control-Max-Age";

	}

	public static class ContentEncoding {
		public static final String GZip = "gzip";
		public static final String Deflate = "deflate";
		public static final String GZipAndDeflate = "gzip, deflate";
	}

	public static class MimeType {
		public static final String OctetStream = "application/octet-stream";
		public static final String URLEncodedForm = "application/x-www-form-urlencoded";
		public static final String UTF8URLEncodedForm = "application/x-www-form-urlencoded;charset=utf8";
		public static final String MultipartFormData = "multipart/form-data";
		public static final String JSON = "application/json";
		public static final String UTF8JSON = "application/json;charset=utf8";
		public static final String PDF = "application/pdf";
		public static final String PList = "application/x-apple-plist";
		public static final String PNG = "image/png";
		public static final String JPEG = "image/jpeg";
		public static final String HTML = "text/html";
		public static final String UTF8HTML = "text/html;charset=utf8";
		public static final String ProtoBuf = "application/vnd.google.protobuf";
	}

}
